//
// Decompiled by Jadx - 599ms
//
package s;

import android.app.Activity;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import androidx.appcompat.app.t;
import cc.c;
import cc.d;
import fg.v;
import fi.y;
import me.plusne.Adapter.Login.g;
import me.plusne.MainActivity;
import me.plusne.common.Http.Vote;
import me.plusne.common.Json.JsonIssueCheck;
import me.plusne.common.Json.VoteSubmit;
import r.f;
import t.a;
import t.b;

public final class ao {
    public JsonIssueCheck a;
    public v b;
    public v c;
    public c d;
    public final Activity e;
    public String f = "";
    public b g;
    public a h;

    public ao(MainActivity mainActivity) {
        this.e = mainActivity;
        m mVar = new m(mainActivity, fn.b.h("autoLogin", false));
        mVar.d(new g(this, mainActivity, mVar, 13));
    }

    public static int i(Activity activity, int i) {
        if (i > 3) {
            return activity.getResources().getColor(-2113535886, null);
        }
        return 0;
    }

    public final void j(EditText editText, int i, int i2) {
        f p;
        String str;
        Activity activity = this.e;
        ((InputMethodManager) activity.getSystemService("input_method")).hideSoftInputFromWindow(editText.getWindowToken(), 0);
        String obj = editText.getText().toString();
        if (obj.isEmpty()) {
            p = androidx.activity.b.p(activity);
            str = "输入评论内容";
        } else if (obj.codePointCount(0, obj.length()) > 100) {
            p = androidx.activity.b.p(activity);
            str = "评论内容不能超过100个字符";
        } else {
            y.e(activity);
            String token = this.a.getToken();
            t.c().j(((Vote) dq.b.b(Vote.class)).comment(token, i2, obj).subscribeWith(new a(this, activity, i, editText)));
            return;
        }
        p.l(str);
    }

    public final void k(int i, int i2, d dVar) {
        VoteSubmit voteSubmit = (VoteSubmit) this.b.e(i);
        int status = voteSubmit.getStatus();
        Activity activity = this.e;
        if (status != 0 && voteSubmit.getStatus() != 1) {
            androidx.activity.b.r(activity, "只有审核成功之前的才可进行投票!");
            return;
        }
        if (voteSubmit.getVote_id() > 0) {
            if (voteSubmit.getVote_type() != 0 || i2 != 0) {
                if (voteSubmit.getVote_type() == 1 && i2 == 1) {
                    return;
                }
            } else {
                return;
            }
        }
        int id = voteSubmit.getId();
        y.e(activity);
        String token = this.a.getToken();
        t.c().j(((Vote) dq.b.b(Vote.class)).like(token, id, i2).subscribeWith(new b(this, activity, i, dVar)));
    }
}
